some bad code - #2
Conversation
codefriar
left a comment
There was a problem hiding this comment.
this is a basic note
| @@ -0,0 +1,8 @@ | |||
| class SimplyBadCode { | |||
| public static void loopExample(){ | |||
There was a problem hiding this comment.
How do you see developers using this method? Does it make sense to keep it static? would an instance method make sense coupled with a static wrapper?
We tend to strive away from static methods, if only because A,B,C.
| public static void loopExample(){ | ||
| for(Integer i = 0; i <500; i++){ | ||
| Contact c = new Contact(name='name '+i); | ||
| insert c; |
There was a problem hiding this comment.
R: When we do DML in a for loop, the platform may trigger Governor limits. <>
We expect code in our codebase to persist lists of information outside of the for loop.
List<Contact> contacts = new List<Contact>();
for(Integer i=0; i<500; i++){
....
}
insert contacts;| @isTest | ||
| private class PartnerAgreement_test { | ||
|
|
||
| @testsetup static void createTestData(){ |
There was a problem hiding this comment.
I love the way we encourage the use of @testsetup methods! Good job.
| //PrdColors test input | ||
| test.starttest(); | ||
|
|
||
|
|
There was a problem hiding this comment.
Perhaps this is the result of a bad branch merge?
When we write tests, we want to make sure that we're asserting the resulting values to ensure the code is working as we expect.
Before we can merge this, we need to address the lack of assertions.
| test.stoptest(); | ||
|
|
||
| } | ||
| @isTest static void test_CMDT_Coverage(){ |
There was a problem hiding this comment.
We want our unit test method names to be very descriptive of what they do! we'll need to refactor this before merge so that we can quickly identify what we expected and what failed.
No description provided.